package com.wang.gateway.config;


import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GatewayConfig {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
                // 自动为每个服务添加文档路由
                .route("oj-system", r -> r.path("http://localhost:9204/doc.html#/home")
                        .uri("lb://oj-system/oj/oj-system-docs"))
                .route("oj-friend", r -> r.path("http://localhost:9201/doc.html#/home")
                        .uri("lb://oj-friend/oj/oj-friend-docs"))
                // 可以添加更多服务...
                .build();
    }
}

